package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cleaningcloud.cld.domain.CldAccountInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.service.ICldAccountInfoService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 账户信息Controller
 * 
 * @author cleaningcloud
 * @date 2025-04-21
 */
@RestController
@RequestMapping("/accountInfo")
public class CldAccountInfoController extends BaseController
{
    @Autowired
    private ICldAccountInfoService cldAccountInfoService;

    /**
     * 查询账户信息列表
     */
    @RequiresPermissions("cld:accountInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(CldAccountInfo cldAccountInfo)
    {
        startPage();
        List<CldAccountInfo> list = cldAccountInfoService.selectCldAccountInfoList(cldAccountInfo);
        return getDataTable(list);
    }

    /**
     * 导出账户信息列表
     */
    @RequiresPermissions("cld:accountInfo:export")
    @Log(title = "导出账户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldAccountInfo cldAccountInfo)
    {
        List<CldAccountInfo> list = cldAccountInfoService.selectCldAccountInfoList(cldAccountInfo);
        ExcelUtil<CldAccountInfo> util = new ExcelUtil<CldAccountInfo>(CldAccountInfo.class);
        util.exportExcel(response, list, "账户信息数据");
    }

    /**
     * 获取账户信息详细信息
     */
    @RequiresPermissions("cld:accountInfo:query")
    @GetMapping(value = "/{accountInfoId}")
    public AjaxResult getInfo(@PathVariable("accountInfoId") Long accountInfoId)
    {
        return success(cldAccountInfoService.selectCldAccountInfoByAccountInfoId(accountInfoId));
    }

    /**
     * 新增账户信息
     */
    @RequiresPermissions("cld:accountInfo:add")
    @Log(title = "新增账户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldAccountInfo cldAccountInfo)
    {
        return toAjax(cldAccountInfoService.insertCldAccountInfo(cldAccountInfo));
    }

    /**
     * 修改账户信息
     */
    @RequiresPermissions("cld:accountInfo:edit")
    @Log(title = "修改账户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldAccountInfo cldAccountInfo)
    {
        return toAjax(cldAccountInfoService.updateCldAccountInfo(cldAccountInfo));
    }

    /**
     * 删除账户信息
     */
    @RequiresPermissions("cld:accountInfo:remove")
    @Log(title = "删除账户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{accountInfoIds}")
    public AjaxResult remove(@PathVariable Long[] accountInfoIds)
    {
        return toAjax(cldAccountInfoService.deleteCldAccountInfoByAccountInfoIds(accountInfoIds));
    }
}
